//
//  AfanBaseController.swift
//  weiboOfAfan
//
//  Created by afan on 16/3/21.
//  Copyright © 2016年 阿范. All rights reserved.
//

import UIKit

class AfanBaseController: UITableViewController {

    var isLogin = AfanUserAccountViewModel.shardInstace.userLogin
    
    
    override func loadView() {
        isLogin ? super.loadView() : willLogin()
    }

    func willLogin(){
        self.view = visitorView
        visitorView.delegate = self
        
        
        if (self is AfanHomeController) {
            visitorView.startRotation()
        }
        else if (self is AfanMessageController) {
        visitorView.setupVisitor("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }
        else if (self is AfanDiscoverController) {
        visitorView.setupVisitor("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }
        else if (self is AfanMeController) {
        visitorView.setupVisitor("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }
        
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidClickRegisterButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitroViewDidClickLoginButton")
        
    }
    
    
    private lazy var visitorView :AfanVisitorView = AfanVisitorView()
    
}
// MARK: - extension扩展,可以在扩展里面实现协议,方便代码管理
extension AfanBaseController : AfanVisitorViewDelegate{
    
    func visitorViewDidClickRegisterButton() {
        print("注册")
    }
    func visitroViewDidClickLoginButton() {
        let oauthVC = AfanOauthController()
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
    }
}


































